<?php

namespace api\modules\v1\models\user;

use api\modules\v1\models\Common;
use common\models\Functions;
use common\models\user\UserLoginStatistic;
use Yii;
use yii\base\Exception;

/**
 * Class UserLoginLog
 * @package api\modules\v1\models\employee
 */
class UserLoginLog extends Common
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%user_login_log}}';
    }
    
    public static function recordLog($userId = 0) {
        if (empty($userId)) {
            return true;
        }
        $insert['login_time'] = date('Y-m-d H:i:s');
        $insert['user_id'] = $userId;
        $insert['login_ip'] = Functions::getRemoteIp();
//        $insert['login_ip'] = Yii::$app->request->getRemoteIP();

        //todo  记录物理位置信息
        static::insertData($insert);
    }
}
